


local mt = ac.skill['特殊护盾']
mt.cool = 5
function mt:on_cooldown()
    local hero = self.owner
    hero:add_buff('特殊护盾'){
        data1 = self.cool,
        on_finish = function(buff)
            if hero:is_alive() then
                self:active_cd()
            end
        end,
    }
end



ac.buff('特殊护盾'){
    physics = true,
    keep = true,
    shield = 0, -- 护盾值
    time = -1,
    data1 = 0,
    model1 = [[36e072fa7add17edbe9bda3d49ad62e2.mdl]],
    on_add = function(self)
        local unit = self.owner 
        self.shield = unit:get('护盾强度') * self.data1 * 2
        self.max_shield = self.shield
        unit:add('护盾',self.shield)
        unit.shield_update = function()
            return self.shield/self.max_shield
        end
        self:gc(unit:add_effect(self.model1))
        self:gc(unit:event "单位-伤害护盾计算" (function (_, _, source, damage)
            local value = damage:get_current_damage()
            if value > 0 then 
                local cost = math.min(self.shield, value)
                self.shield = self.shield - cost 
                unit:add('护盾',- cost)
                value = value - cost
                damage:set_current_damage(value)
                if self.shield <= 0 then 
                    -- 护盾破碎的时候触发
                    self:notify("on_finish")
                    self:remove()
                end
                if value <= 0 then 
                    return true
                end
            end 
        end))
        self:gc(function()
            unit:add('护盾',-self.shield)
            unit.shield_update = nil
        end)
    end,
    on_cover = function(new)
        return true
    end
}